<?php

class HomeController extends MyController
{
	function init() {parent::init();}
	
	function actionIndex()
	{
		$this->render("index");
	}
	
	function actionDelete_db()
	{
		// Create Connection 
		$this->conn = Yii::app()->db;
		$this->conn->createCommand("DROP DATABASE IF EXISTS " . DB_NAME)->execute();
		$this->conn->createCommand("CREATE DATABASE " . DB_NAME)->execute();
		$this->redirect(array("home/index"));
	}
	
	function actionWebsite()
	{
		$file = $this->sql_folder . "/website.sql";

		$dsn = 'mysql:host='.HOST_NAME.';dbname='.DB_NAME;
		$username = USER_NAME;
		$password = PASS_WORD;
		
		$this->conn = new CDbConnection($dsn,$username,$password);
		$this->run_sql($file);
		$this->redirect(array("home/index"));
	}	
}